package acidcart.client;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.TabLayoutPanel;
import com.google.gwt.user.client.ui.Widget;

//////////////////////////////////////////////////////////////////////
/// NOTE: Replacing all "build" methods with either VIEWs or FACTORYs
///		  Construction of the site will be done from here for now.
///		  A method of the entry point can be used in the future.
//////////////////////////////////////////////////////////////////////
public class WidgetLibrary {

	public WidgetLibrary(){}

	public Widget getHomePanelContents()
	{
		return new HTML("Home Page");
	}
	public Widget getProductsPanelContents() 
	{
		HTML pageHTML = new HTML("<span style='font-weight: bold;'>YOU WILL RECEIVE: 1 (ONE): Platinum testing deluxe kit.</span> Test Kit Includes: Easy to follow instructions, 5gn platinum bar, 100 as 100g x 0.01g digital scale, 30x puritest magnifier, precious metal testing file, 2 x precious metal testing stonesand 1/2oz bottle of platinum purity testing solution that provides fast test results. Platinum testing solutions are specially made for easy and accurate testing. The solution will change color immediately if the metal is not platinum.<br><br style='font-style: italic;'><span style='font-style: italic;'>Platinum testing solution can also be used for 18k and 14K white gold. Only a small drop is needed to test, so you will get hundreds of tests out of each bottle! The 100as jewelry scale is small to fit in your pocket, but very accurate and reliable. It can be used for weighing gold, siler, diamond and other precious stones with 1/100th gram accuracy.		  </span><br><br></font><strong>Satisfaction Guaranteed:</strong><br>  <strong><em>30-DAY MONEY BACK GUARANTEE!</em></strong><br>  If you are unhappy with your purchase you may return the item for a full refund, no questions asked!<strong></strong><br><p>  <strong>Shipping &amp; Handling:</strong><br></p><p><em>FREE EXPEDITED USA SHIPPING!</em><br>  SHIPPING:  Free first class shipping for all US customers with free delivery tracking with <em><strong>no handling fees!</strong></em><strong></strong><br>  <strong>International customers:</strong> We offer the <em>lowest price international shipping possible! <br>  You pay only the exact shipping cost based on your</em> <em>location with <strong>no handling fees!</strong></em><br>  </p><p><font><font style='font-family: Arial;' size='2'><strong>Return Policy:</strong><br>  All   of our scales are backed by a lifetime warranty. If you have any problems   with the scale return it and we will send you a replacement, fast and hastle free!<br>  All   test kits are backed by a 30-day money back guarantee.&nbsp; All precious metals sales are final, please contact us if you have anyquestions. </font></font><br><br><strong>Thank You!</strong><br>It   is our goal to provide the best products precious metals bullionand   jewelry testing equipment and supplies along with award winning customer service.&nbsp; <br>Contact us if you have any questions, and we will help you find the answer.</p>");
		return pageHTML;
	}
	public Widget getContactsPanelContents()
	{
		return new ContactInfoView().asWidget();
	}
	public Widget getHelpPanelContents()
	{
		return new HTML("Help Page.");
	}
	
	
	public Widget getMainTabLayoutPanel()
	{
		TabLayoutPanel tabPanel =  new TabLayoutPanel(2, Unit.EM);
	    tabPanel.setAnimationDuration(1000);
	    
		tabPanel.add(getHomePanelContents(), "Home");
		tabPanel.add(getProductsPanelContents(), "Products");
		tabPanel.add(getContactsPanelContents(), "Contacts");
		tabPanel.add(getHelpPanelContents(), "Help");
		tabPanel.selectTab(0);
		
		return tabPanel;
	}
	
	public Widget getDockLayoutPanel()
	{
		// Button not added anywhere now.
	    Button openButton = new Button("Look Here!");
	    final DialogBox openDialog = PopupFactory.StandardDialog(new Image("images/acid.png"),"Look!");
	    openButton.addClickHandler(new ClickHandler() {
          public void onClick(ClickEvent event) {openDialog.center();}
        });
	    

		DockLayoutPanel docPanel = new DockLayoutPanel(Unit.EM);
		docPanel.addNorth(getHeaderPanel(), 10);
		docPanel.addWest(getLoginPanel(), 20);
		docPanel.add(getMainTabLayoutPanel());
		
		return docPanel;
	}
	
	public Widget getLoginPanel()
	{
		return new LoginView().asWidget();
	}
	
	public Widget getHeaderPanel()
	{
		FlowPanel headerFlow = new FlowPanel();
		headerFlow.add(new Image("images/AcidCartLogo_small.png"));
		return headerFlow;
	}

}
